﻿using cpe.cpein.SERVER.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace cpe.cpein.SERVER.Tools
{
    public static partial class ObjectConverter
    {
        /// <summary>
        /// Function used to convert a WS Area to a Data Area.
        /// </summary>
        /// <param name="?"></param>
        /// <returns></returns>
        public static DATA.Area AreaConverter(Area Area)
        {
            if (Area == null)
                return null;

            return new DATA.Area()
            {
                are_id = Area.Id,
                are_label = Area.Label,
                are_isdeleted = Area.IsDeleted,
            };
        }

        /// <summary>
        /// Function used to convert a Data Area to a WS Area.
        /// </summary>
        /// <param name="?"></param>
        /// <returns></returns>
        public static Area AreaConverter(DATA.Area Area)
        {
            if (Area == null)
                return null;

            return new Area()
            {
                Id = Area.are_id,
                Label = Area.are_label,
                IsDeleted = Area.are_isdeleted,
            };
        }

        /// <summary>
        /// Function used to convert a list of Data Areas to a List of WS Areas.
        /// </summary>
        /// <param name="Areas"></param>
        /// <returns></returns>
        public static List<Area> AreaConverter(List<DATA.Area> Areas)
        {
            List<Area> res = new List<Area>();
            foreach (DATA.Area us in Areas)
                res.Add(Tools.ObjectConverter.AreaConverter(us));

            return res;
        }

        /// <summary>
        /// Function used to convert a list of WS Areas to a List of Data Areas.
        /// </summary>
        /// <param name="Areas"></param>
        /// <returns></returns>
        public static List<DATA.Area> AreaConverter(List<Area> Areas)
        {
            List<DATA.Area> res = new List<DATA.Area>();
            foreach (Area us in Areas)
                res.Add(Tools.ObjectConverter.AreaConverter(us));

            return res;
        }
    }
}